<?php
namespace app\controller;

use app\BaseController;

class Sign extends BaseController
{
    //生成签名
    public static function Sign($params, $key)
    {
        ksort($params);
        $params =  urldecode(http_build_query($params));
        $params .= "&key={$key}";
        return strtoupper(md5($params));
    }
    //解密
    public function encrypt(string $data, $key): string
    {
        $APIIV = env('main_openUrl','qb82jd75anjxdxka');
        $encrypted = openssl_encrypt($data, "AES-128-CBC", $key, true, $APIIV);
        return base64_encode($encrypted);
    }
}
